/* 
* @Author: kong
* @Date:   2018-01-25 17:34:13
* @Last Modified by:   anchen
* @Last Modified time: 2018-03-14 22:53:00
*/
;(function(factory){
    if(typeof define === 'function' && define.amd){
        define(['jquery','lodash'],factory);
    }else if (typeof exports !== 'undefined') {
        // For Node.js or CommonJS.
        var _ = require('lodash');
        var $ = require('jquery');
    }else{
         factory(jQuery,_);
    }   
}(function($,_){
    //防冲突处理，如果原型链上有，将之移给old变量
    var old = $.fn.password;
    //构造函数
    var Password=function Password(element,options){
      var self=this;
        this.$element = $(element);
        this.options = $.extend({},$.fn.password.defaults,options);
        this.init();
        // if(typeof this.options.dataUrl!=="undefined"){
        //     this.initMainHtml(this.options.dataUrl);
        //   };
       
    };
    // 定义原型
    Password.prototype ={
        // 初始化
        init:function(){
          this.initBasicsHtml(this.options.data);
          
        },
        initBasicsHtml:function(data){
            var self=this;
          var html='';
            html+='<div class="dropSortableCon itemselected" id="'+data.template+self.options.idNum+'">'
                +'<div class="boxMain clear" data-template="'+data.template+'">'
                +'<div class="">';

            html+='<div class="form-group">'
                +'<label for="'+self.options.idNum+'" class="col-xs-2 control-label">密码</label>'
                +'<div class="col-xs-10">'
                +'<input placeholder="请输入字段预期提示信息" name="name_'+self.options.idNum+'" id="'+self.options.idNum+'" type="password" class="form-control password">'
                +'</div>'
                +'</div>';

            html+='</div>'
                +'</div>'
                +'</div>';
          if(this.options.basicsHtml!=="undefined"){
            var dataObject={};
            dataObject.html=html;
            this.options.basicsHtml.call(this,dataObject)
          }
        },
        // initMainHtml:function(dataUrl){
        //     $.ajax({
        //       type: "GET",
        //       url: dataUrl,
        //       dataType:"json",
        //       async: true,
        //       contentType:"application/json",
        //         success: function(data){
        //           alert("组件有url时执行的代码")
        //         }
        //     });
          
          

        // }
       


    };


    // 为了避免多次实例化
    $.fn.password = function password(option,value) {
        var retval;
        var $set = this.each(function () {
            var $this = $(this);
            var data = $this.data('makerui.password');
            var options = typeof option === 'object' && option;

            $this.data('makerui.password', (data = new Password(this, options)));
            if (typeof option === 'string') retval = data[option](value);
        });
        return (retval === undefined) ? $set : retval;
    };
    
    $.fn.password.defaults = {

       
    };
    $.fn.password.Constructor = Password;
    $.fn.password.noConflict = function () {
        $.fn.password = old;
        return this;
    }; 













}));